import axios from 'axios'
import config from '@/config'

const api = axios.create({
  baseURL: config.API_URL,
  timeout: config.timeout
})

// request拦截器
api.interceptors.request.use(config => {
  return config
}, error => {
  console.log(error)
  Promise.reject(error)
})

// response拦截器
api.interceptors.response.use(response => response,
  error => {
    console.log(error)
    return Promise.reject(error)
  }
)

export default api
